package com.li.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;

import com.ndboo.reslibrary.R;

/**
 * Author: Li
 * Date: 2017/11/13 0013
 * Description: "我的"界面操作条目
 */

public class MineItemView extends FrameLayout {
    public MineItemView(@NonNull Context context) {
        this(context,null);
    }

    public MineItemView(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        View view= LayoutInflater.from(context).inflate(R.layout.item_mine_view,this);
        ImageView imgLeft=view.findViewById(R.id.img_left);
        TextView text=view.findViewById(R.id.txt);
        ImageView imgRight=view.findViewById(R.id.img_right);

        TypedArray array=context.obtainStyledAttributes(attrs,R.styleable.MineItemView);
        int imgLeftResource=array.getResourceId(R.styleable.MineItemView_img_left,R.drawable.default_img);
        int imgRightResource=array.getResourceId(R.styleable.MineItemView_img_right,R.drawable.ic_arrow_right);
        String txt=array.getString(R.styleable.MineItemView_txt_des);
        array.recycle();

        imgLeft.setImageResource(imgLeftResource);
        imgRight.setImageResource(imgRightResource);
        text.setText(txt);
    }
}
